<template>
  <div class="photoinfo-container">
    <h3>{{photoinfo.title}}</h3>
    <p class="subtitle">
      <span>发表时间：{{photoinfo.add_time | dateFormat}}</span>
      <span>点击：{{photoinfo.click}}次</span>
    </p>

    <hr>

    <!-- 脱略图区域 -->
    <!--插件： https://github.com/LS1231/vue-preview  -->
    <vue-preview :slides="list" @close="handleClose"></vue-preview>

    <!-- 图片内容区域 -->
    <div class="content" v-html="photoinfo.content"></div>

    <!-- 放置一个现成的评论子组件 -->
    <cmt-box :cmtid="id"></cmt-box>

  </div>
</template>

<script>
  // 1. 导入评论子组件
  import comment from '../subcomponents/comment.vue'

  export default {
    data(){
      return {
        id: this.$route.params.id,  //从路由获取到图片的ID
        photoinfo: {},  //图片详情
        list: [
          {
            src: 'https://farm6.staticflickr.com/5591/15008867125_68a8ed88cc_b.jpg',
            msrc: 'https://farm6.staticflickr.com/5591/15008867125_68a8ed88cc_m.jpg',
            alt: 'picture1',
            title: 'Image Caption 1',
            w: 600,
            h: 400
          },
          {
            src: 'https://farm4.staticflickr.com/3902/14985871946_86abb8c56f_b.jpg',
            msrc: 'https://farm4.staticflickr.com/3902/14985871946_86abb8c56f_m.jpg',
            alt: 'picture2',
            title: 'Image Caption 2',
            w: 1200,
            h: 900
          },
          {
            src: 'https://farm6.staticflickr.com/5591/15008867125_68a8ed88cc_b.jpg',
            msrc: 'https://farm6.staticflickr.com/5591/15008867125_68a8ed88cc_m.jpg',
            alt: 'picture3',
            title: 'Image Caption 3',
            w: 600,
            h: 400
          },
          {
            src: 'https://farm4.staticflickr.com/3902/14985871946_86abb8c56f_b.jpg',
            msrc: 'https://farm4.staticflickr.com/3902/14985871946_86abb8c56f_m.jpg',
            alt: 'picture4',
            title: 'Image Caption 4',
            w: 1200,
            h: 900
          }
        ]
      }
    },
    created(){
      this.getPhotoInfo()
    },
    methods:{
      getPhotoInfo(){ //获取图片详情
       /*  this.$httpget("api/getimageInfo" + this.id).then(result=>{
          if(r.esult.body.status === 0){
            this.photoinfo = result.body.message[0]
          }
        }) */
         // 模拟数据 
        var imgInfo = 
        {
          add_time:"2018-03-04T10:10:00",
          click:0,
          content: "不哎哟简朴不要想起的我是我做主，高低榻榻米我是我是装扮,不哎哟简朴不要想起的我是我做主，高低榻榻米我是我是装扮,不哎哟简朴不要想起的我是我做主，高低榻榻米我是我是装扮",
          id:1,
          title:"现代简约明亮的外表我是背景墙、吊顶黄色"
        }
        this.photoinfo = imgInfo
      },
      handleClose () {
        console.log('close event')
      }
    },
    components:{ //注册评论子组件
      'cmt-box' : comment
    }
  }
</script>

<style lang="scss" scoped>
.photoinfo-container{
  padding: 3px;
  h3{
    color:#26A2FF;
    font-size:15px;
    text-align: center;
    margin: 15px 0;
  }
  .subtitle{
    display: flex;
    justify-content: space-between;  //css3中的弹性盒模型
    font-size: 13px;
  }
  .content{
    font-size: 13px;
    line-height: 30px;
  }
}
</style>

